/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DomainListPanel.java
 *
 * Created on 2009-1-17, 23:18:46
 */

package com.guzzservices.easydomain.ui.panel;

import com.guzzservices.easydomain.logic.domain.TopDomain;
import com.guzzservices.easydomain.ui.frame.ARecordListFrame;
import com.guzzservices.easydomain.util.ComponentCenter;
import javax.swing.JTable;

/**
 *
 * @author Administrator
 */
public class DomainListPanel extends javax.swing.JPanel {

    /** Creates new form DomainListPanel */
    public DomainListPanel() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        topDomainTable = new javax.swing.JTable();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(com.guzzservices.easydomain.ui.frame.DDSProjectApp.class).getContext().getResourceMap(DomainListPanel.class);
        setBackground(resourceMap.getColor("Form.background")); // NOI18N
        setName("Form"); // NOI18N

        jPanel1.setBackground(resourceMap.getColor("jPanel1.background")); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setForeground(resourceMap.getColor("jLabel1.foreground")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE)
                .add(454, 454, 454))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
        );

        jScrollPane1.setBackground(resourceMap.getColor("jScrollPane1.background")); // NOI18N
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        topDomainTable.setModel(new com.guzzservices.easydomain.ui.render.TopDomainTableDataModel());
        topDomainTable.setIntercellSpacing(new java.awt.Dimension(8, 4));
        topDomainTable.setName("topDomainTable"); // NOI18N
        topDomainTable.setRowHeight(25);
        topDomainTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        topDomainTable.getTableHeader().setReorderingAllowed(false);
        topDomainTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                topDomainTableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(topDomainTable);
        topDomainTable.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void topDomainTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_topDomainTableMouseClicked
        if(evt.getClickCount() == 2){
            TopDomain td = ComponentCenter.getSelectedTopDomain() ;
            if(td != null){
                ARecordListFrame f = new ARecordListFrame(td) ;
                f.setLocation(ComponentCenter.getInstance().getRightMainViewPopWindowLocation()) ;
                f.setVisible(true) ;
            }
        }
    }//GEN-LAST:event_topDomainTableMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable topDomainTable;
    // End of variables declaration//GEN-END:variables

    public JTable getTopDomainTable() {
        return topDomainTable;
    }

}
